home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / pascal / totsrc11.zip / EXTIO.PAS < prev    next >
Pascal/Delphi Source File  |  1993-05-04  |  4KB  |  143 lines

  1. {               Copyright 1991 TechnoJock Software, Inc.               }
  2. {                          All Rights Reserved                         }
  3. {                         Restricted by License                        }
  4.  
  5. {                             Build # 1.00                             }
  6. {                        Adds a Boolean field                          }
  7. Unit ExtIO;
  8. {$I TOTFLAGS.INC}
  9.  
  10. {
  11.  Development Notes:
  12.  
  13. }
  14. INTERFACE
  15.  
  16. uses DOS, CRT, totFAST, totIO1, totSTR, totInput;
  17.  
  18. TYPE
  19. BooleanIOOBJ = object (VisibleIOOBJ)
  20.    OnString: StringBut;
  21.    OffString: StringBut;
  22.    vInput: boolean;
  23.    {methods...}
  24.    constructor Init(X,Y:byte; Yes,No:stringbut);
  25.    function    GetValue: boolean;
  26.    procedure   SetValue(On:boolean);
  27.    procedure   Activate;
  28.    procedure   Display(Status:tStatus);                  VIRTUAL;
  29.    function    Select(K:word; X,Y:byte):tAction;         VIRTUAL;
  30.    function    ProcessKey(InKey:word;X,Y:byte):tAction;  VIRTUAL;
  31.    function    Suspend:boolean;                          VIRTUAL;
  32.    destructor  Done;                                     VIRTUAL;
  33. end; {BooleanIOOBJ}
  34.  
  35. IMPLEMENTATION
  36.  
  37. constructor BooleanIOOBJ.Init(X,Y:byte; Yes,No:stringbut);
  38. {}
  39. var L:byte;
  40. begin
  41.    VisibleIOOBJ.Init;
  42.    OnString := Yes;
  43.    OffString := No;
  44.    L := length(OnString);
  45.    if L < length(OffString) then
  46.       L := length(OffString);
  47.    with vBoundary do
  48.    begin
  49.       X1 := X;
  50.       X2 := X + pred(L);
  51.       Y1 := Y;
  52.       Y2 := Y;
  53.    end;
  54.    vInput := true;
  55. end; {BooleanIOOBJ.Init}
  56.  
  57. function BooleanIOOBJ.GetValue: boolean;
  58. {}
  59. begin
  60.    GetValue := vInput;
  61. end; {BooleanIOOBJ.GetValue}
  62.  
  63. procedure BooleanIOOBJ.SetValue(On:boolean);
  64. {}
  65. begin
  66.    vInput := On;
  67. end; {BooleanIOOBJ.SetValue}
  68.  
  69. procedure BooleanIOOBJ.Display(Status:tStatus);                  
  70. {}
  71. var Att: byte;
  72. begin
  73.    case Status of
  74.       HiStatus: Att := IOTOT^.FieldCol(2);
  75.       Norm:     Att := IOTOT^.FieldCol(1);
  76.       Off:      Att := IOTOT^.FieldCol(4);
  77.    end; {case}
  78.    with vBoundary do
  79.       if vInput then
  80.          Screen.WriteAT(X1,Y1,Att,padleft(OnString,succ(X2-X1),' '))
  81.       else
  82.          Screen.WriteAT(X1,Y1,Att,padleft(OffString,succ(X2-X1),' '));
  83. end; {BooleanIOOBJ.Display}
  84.  
  85. function BooleanIOOBJ.Select(K:word; X,Y:byte):tAction;         
  86. {}
  87. begin
  88.    Display(HiStatus);
  89.    WriteLabel(HiStatus);
  90.    WriteMessage;
  91.    Screen.GotoXY(vBoundary.X1,vBoundary.Y1);
  92.    Select := none;
  93. end; {BooleanIOOBJ.Select}
  94.  
  95. function BooleanIOOBJ.ProcessKey(InKey:word;X,Y:byte):tAction;  
  96. {}
  97. begin
  98.    if (InKey = 513) 
  99.    or (InKey = 32) 
  100.    or (inKey = 328) 
  101.    or (InKey = 336) then
  102.    begin
  103.       vInput := not vInput;
  104.       Display(HiStatus);
  105.    end;
  106.    if InKey = 513 then {absorb mouse}
  107.       delay(100);
  108.    if (InKey = 13) then
  109.       ProcessKey := Enter
  110.    else
  111.       ProcessKey := None;
  112. end; {BooleanIOOBJ.ProcessKey}
  113.  
  114. procedure BooleanIOOBJ.Activate;
  115. {}
  116. var
  117.    Action: tAction;
  118. begin
  119.    Action := Select(0,0,0);
  120.    Display(HiStatus);
  121.    WriteLabel(HiStatus);
  122.    with Key do 
  123.    begin
  124.       repeat
  125.          GetInput;
  126.          Action := ProcessKey(LastKey,LastX,LastY);
  127.       until ((LastKey = 324) or (LastKey = 13)) and Suspend;
  128.    end;
  129. end; {BooleanIOOBJ.Activate}
  130.  
  131. function BooleanIOOBJ.Suspend:boolean;                        
  132. {}
  133. begin
  134.    Suspend := VisibleIOOBJ.Suspend;
  135. end; {BooleanIOOBJ.Suspend}
  136.  
  137. destructor BooleanIOOBJ.Done;                                     
  138. {}
  139. begin
  140.    VisibleIOOBJ.Done;
  141. end; {BooleanIOOBJ.Done}
  142.  
  143. end.